<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible">
<title>收货地址--<!--{$mallname}--></title>
<!--{include(file='static.html')}-->
</head>
<body>
<!--{include(file='head.html')}-->
<script src="template/jslib/country/country.js" type="text/javascript"></script>
    <!--主体内容-->
	<div class="container">
    <!--左侧菜单-->
		<div class="per_left">
            <!--{include(file='userleft.html')}-->
        </div>
        <!--左侧菜单end-->
        <div class="per_right">
        	<div class="per_right_cont">
            	<h3>收货地址</h3>
				<!--{if $hint}-->
				<p class="userhint<!--{$hint.type}-->">
					<!--{$hint.hint}-->
				</p>
				<!--{/if}-->
				 <form action="<!--{url('index','member','address')}-->" name="theform" id="theform" method="post" onsubmit="return checkform()">
					<div class="add_list3">
						<!--{if $opertype =='add'}-->
							<h1 class="redh1">新增地址</h1>
							<ul>
								<li>
									<label><em>*</em>收货人姓名：</label>
									<p>
										<input type="text" name="receiver" id="receiver"/> 
									</p>
								</li>
								<li>
									<label><em>*</em>收货区域：</label>
									<p>
										<select name="province" id="province" onchange="$.country.getCity()" autocomplete="off">
										</select>
										-
										<select name="city" id="city" onchange="$.country.getDistrict()" autocomplete="off">
										</select>
										-
										<select name="district" id="district" onchange="$.country.getZip()"  autocomplete="off">
										</select>
										
									</p>
								</li>
								<li>
									<label><em>*</em>街道地址：</label>
									<p>
										<input type="text" name="address" id="address" size="40"/>
									</p>
								</li>
								<li>
									<label><em>*</em>邮政编码：</label>
									<p>
										<input type="text" name="zipcode" id="zipcode" autocomplete="off"/>
										<script type="text/javascript">
											$.country.init(true);
										</script>
									</p>
								</li>
								<li>
									<label><em>*</em>电话/手机：</label>
									<p>
										<input type="text" name="link" id="link" />
									</p>
								</li>
								<li>
									<label>&nbsp;</label>
									<p>
										<input type="submit" class="o_button" value="保 存"/>
									</p>
								</li>
							</ul>
						<!--{elseif $opertype == 'edit'}-->
							<h1 class="redh1">修改地址</h1>
							<ul>
								<li>
									<label><em>*</em>收货人姓名：</label>
									<p>
										<input type="text" name="receiver" id="receiver" value="<!--{$address.receiver}-->"/> 
									</p>
								</li>
								<li>
									<label><em>*</em>收货区域：</label>
									<p>
										<select name="province" id="province" onchange="$.country.getCity()" autocomplete="off">
											<!--{$provinceopt}-->
										</select>
										-
										<select name="city" id="city" onchange="$.country.getDistrict()"  autocomplete="off">
											<!--{$cityopt}-->
										</select>
										-
										<select name="district" id="district"  autocomplete="off" onchange="$.country.getZip()">
											<!--{$districtopt}-->
										</select>
									</p>
								</li>
								<li>
									<label><em>*</em>街道地址：</label>
									<p>
										<input type="text" name="address" id="address" value="<!--{$address.address}-->" size="40"/>
									</p>
								</li>
								<li>
									<label><em>*</em>邮政编码：</label>
									<p>
										<input type="text" name="zipcode" id="zipcode" value="<!--{$address.zipcode}-->" autocomplete="off"/>
										<script type="text/javascript">
											$.country.init(false);
										</script>
									</p>
								</li>
								<li>
									<label><em>*</em>电话/手机：</label>
									<p>
										<input type="text" name="link" id="link" value="<!--{$address.link}-->"/>
									</p>
								</li>
								<li>
									<label>&nbsp;</label>
									<p>
										<input type="submit" class="o_button" value="保 存"/>
									</p>
								</li>
							</ul>
						<!--{/if}-->
				</div>
				
				<div class="add_list">
                	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <th width="10%">操作</th>
						<th width="15%">收货人</th>
                        <th width="20%">收货地区</th>
                        <th width="10%">邮编</th>
                        <th width="20%">电话/手机</th>
                      </tr>
					  <!--{foreach $addresslist address}-->
                      <tr id="tr_<!--{$address.addressid}-->">
                        <td class="memberoper">
							<a href="<!--{url('index','member','address','op=edit&addressid=$address[addressid]')}-->">修改</a> | 
							<a href="javascript:void(0)" onclick="jsdel('<!--{$address['addressid']}-->');return false;">删除</a>
						</td>
						<td><!--{$address.receiver}--></td>
                        <td>
							<!--{getDistrict($address.province,$address.city,$address.district)}--><!--{$address.address}-->
						</td>
                        <td><!--{$address.zipcode}--></td>
                        <td><!--{$address.link}--></td>
                      </tr>
					  <!--{/foreach}-->
                    </table>
				 </div>
            </div>
        </div>
        <div class="clear"></div>
	</div>
    <!--主体内容 end-->
<!--{include(file='foot.html')}-->
</body>
</html>
<script type="text/javascript">
function jsdel(addressid) {
	if(jConfirm("确认删除吗？","删除地址",function(con){
		if(con) {
			$.post("<!--{url('index','member','deladdress')}-->",{addressid:addressid},function(data){
				if(data == "success") {
					$("#tr_"+addressid).remove();
				} else {
					jAlert("删除错误，请刷新后重新执行","删除错误");
				}
			});
		}
	}));
}
function checkform() {
	var receiver = $.trim($("#receiver").val());
	if(!receiver) {
		jAlert("请输入收货人姓名！");
		return false;
	}

	var province = $.trim($("#province").val());
	if(!province) {
		jAlert("请选择省");
		return false;
	}
	var city	= $.trim($("#city").val());
	if(!city) {
		jAlert("请选择市");
		return false;
	}

	var district	= $.trim($("#district").val());
	if(!district) {
		jAlert("请选择区");
		return false;
	}

	var address	= $.trim($("#address").val());
	if(!address) {
		jAlert("请输入街道地址");
		return false;
	}

	var link	= $.trim($("#link").val());
	if(!link) {
		jAlert("请输入联系电话/手机");
		return false;
	}
	return true;
}
</script>
